/*******************************************************************
* Author	: wwyang
* Date		: 2006.6.13
* Copyright : State key CAD&CG Lab, Group of Animation 
* Head File : Structure for base class of commands
* Note      : This structure is taken from a project that i finished
              in March, 2006
* Version   : 1.0
*********************************************************************/

#ifndef _BASECOMMAND_H_
#define _BASECOMMAND_H_
#pragma warning(disable: 4995)


//#include "..\ABSView.h" // For UI view

//////////////////////////////////////////////////////////////////////////
// class of message to be passed to command for handling

class CMsg{
public:
	enum MSG_TYPE{ KEY_DOWN, KEY_UP, LBUTTONDOWN, LBUTTONUP, MBUTTONDOWN, MBUTTONUP, RBUTTONDOWN, RBUTTONUP, MOUSEMOVE, CHAR, CUSTOM };

	// message data
public:
// Commented by not compatient with dxut
//	ABSView *_pView;   // refer to parent gl window
//	CPoint _point;      // mouse position
	MSG_TYPE _msgType;  // message type

	//UINT _nChar, _nRepCnt, _nFlags; // key&char message
};

//////////////////////////////////////////////////////////////////////////
// This a base class of command. a concrete command class derived from it
// may override the virtual functions to response the command operation

class CCmdBase{
	// constructor and destructor
public:
	CCmdBase(){}
	~CCmdBase(){}

	// command operation
public:
	void BeginCmd();
	void EndCmd();

protected:
	// When a command is invoked, should do something for other 
	// currently alive commands
	virtual void ModifyOtherCmdState();

	// When a command begin|end, it may need to create or clear
	// some data
	virtual void BeginCmdImplement(){}
	virtual void EndCmdImplement(){}

	// message handler
public:
	// Handler messages passed to the cmd when it's running
	virtual void HandleMsg(CMsg& msg){}

	// state
public:
	bool IsAlive() const
	{ return _bIsAlive; }

protected:
	bool _bIsAlive;
};

#endif